<!-- 
 * @description: 步骤条
 * @fileName: BStepNew.vue 
 * @author: xp 
 * @date: 2023-07-10 11:49:26
-->
<template>
  <div class="steps-new-container">
    <div :class="['step', { 'currentStep backgroundTheme': current >= index }]" v-for="(item, index) in stepsList" :key="index" @click="handleChangeCurrent(index)">
        <div v-if="index !== 0 && current >= index">
            <div class="rect"></div>
            <div class="triangle1"></div>
            <div class="triangle2"></div>
        </div>
        {{index+1}}.{{ item.title }}
    </div>
  </div>
</template>
<script>
export default {
  name: 'BStepNew',
  props: {
    // 是否点击改变背景
    isChangeBg: {
        type: [Boolean],
        default: () => true
    },
    
    // 当前步骤
    current: {
      type: Number,
      default: function () {
        return 0;
      },
    },
    // 步骤条列表
    stepsList: {
      type: Array,
      default: function () {
        return [];
      },
    },
    // 是否改变icon
    isChangeIcon: {
      type: Boolean,
      defalut: () => true,
    },
  },
  data () {
    return {
    }
  },
  created() {
    
  }, 
  mounted() {
    
  },
  methods: {
    // 切换tab
    handleChangeCurrent(e) {
      if (!this.isChangeIcon) {
        this.$emit("change", e);
      }
    }
  }
}
</script>
<style lang="scss" scoped>
@import '../../styles/variables.scss';
@import '../../styles/_handle.scss';
@import '../../styles/themes.scss';
.steps-new-container{
    display: flex;
    align-items: center;
    background-color: #fff;
    border-radius: 8px;
    margin-bottom: 16px;
    overflow: hidden;
    .step{
        position: relative;
        flex: 1;
        text-align: center;
        height: 54px;
        line-height: 54px;
        font-size: 16px;
        color: rgba(0, 0, 0, 0.85);
        font-weight: 400;
        cursor: pointer;
        .rect{
            position: absolute;
            left: 0;
            top: 0;
            bottom: 0;
            width: 5px;
            background: #fff;
        }
        .triangle1{
            position: absolute;
            left: 5px;
            top: 0;
            bottom: 0;
            height: 0;
            @include themeify {
                border-left: 27px solid #fff;
            }
            border-top: 27px solid transparent;
            border-bottom: 27px solid transparent;
            z-index: 10;
        }
        .triangle2{
            position: absolute;
            left: 0;
            top: 0;
            bottom: 0;
            height: 0;
            @include themeify {
                border-left: 27px solid themed('colorTheme');
            }
            border-top: 27px solid transparent;
            border-bottom: 27px solid transparent;
            z-index: 11;
        }
    }
    .currentStep{
        position: relative;
        color: #fff;
        &::after{
            position: absolute;
            right: -26px;
            top: 0;
            bottom: 0;
            height: 0;
            @include themeify {
                border-left: 27px solid themed('colorTheme');
            }
            border-top: 27px solid transparent;
            border-bottom: 27px solid transparent;
            content: '';
        }
    }
}
</style>